package unclassified.medium;

import java.util.Random;

public class ShuffleAnArray_384 {

    int[] res;
    Random random;
    ShuffleAnArray_384(int[] nums) {
       res = nums;
        random = new Random();
    }

    public int[] reset() {
        return res;
    }

    public int[] shuffle() {
        int[] arr = res.clone();
        for (int i = 0; i < res.length; i++) {
            swap(arr, i, i + random.nextInt(res.length - i));
        }
        return arr;
    }

    public void swap(int[] a, int i, int j) {
        int temp = a[i];
        a[i] = a[j];
        a[j] = temp;
    }

}
